package view;

import java.awt.Color;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class MenuBar extends JMenuBar {
	/**
	 * 
	 */
	private static final long serialVersionUID = 8909606522848084831L;
	private JMenuItem bet;
	private JMenuItem hit;
	private JMenuItem stand;
	private JMenuItem surrender;
	private JMenuItem newGameItem;
	private JMenuItem LoadItem;
	private JMenuItem SaveItem;

	public MenuBar(JFrame frame) {
		// this.setTitle("MenuBarTest1");
		// panel = new JPanel();
		// frame.getContentPane().add(panel);

		/*
		 * Skapa en menyrad och addera den till framen
		 */
		JMenuBar menuBar = new JMenuBar();
		frame.setJMenuBar(menuBar);

		// Skapa en meny, "File" och addera menyn till menyraden
		JMenu fileMenu = new JMenu("File");
		menuBar.add(fileMenu);

		newGameItem = new JMenuItem("New Game");
		fileMenu.add(newGameItem);

		LoadItem = new JMenuItem("Load Game");
		fileMenu.add(LoadItem);

		SaveItem = new JMenuItem("Save Game");
		fileMenu.add(SaveItem);

		// Skapa ett menyalternativ, "Exit" och l���gg till detta till menyn
		JMenuItem quitItem = new JMenuItem("Exit");
		fileMenu.add(quitItem);

		// Associera en lyssnare till h���ndelsek���llan, h���r skapad med
		// en anonym inre klass
		quitItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent ae) {
				System.exit(0);// die :@
			}
		});

		// newGameItem.addActionListener(newgame);

		JMenu gameMenu = new JMenu("Game");
		menuBar.add(gameMenu);

		bet = new JMenuItem("Bet");
		gameMenu.add(bet);

		hit = new JMenuItem("Hit");
		gameMenu.add(hit);

		stand = new JMenuItem("Stand");
		gameMenu.add(stand);

		surrender = new JMenuItem("Surrender");
		gameMenu.add(surrender);

	}

	public void setMenuBetListener(ActionListener al) {
		bet.addActionListener(al);

	}

	public void setMenuHitListener(ActionListener al) {
		hit.addActionListener(al);
	}

	public void setMenuStandListener(ActionListener al) {
		stand.addActionListener(al);
	}

	public void setMenuSurrenderListener(ActionListener al) {
		surrender.addActionListener(al);
	}

	public void setMenuNewGameListener(ActionListener al) {
		newGameItem.addActionListener(al);
	}

	public void setMenuLoadListener(ActionListener al) {
		LoadItem.addActionListener(al);
	}

	public void setMenusSaveListener(ActionListener al) {
		SaveItem.addActionListener(al);
	}
}
